# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.RecommendationEngine.V1beta1.Model.GoogleCloudRecommendationengineV1beta1ProductDetail do
  @moduledoc """
  Detailed product information associated with a user event.

  ## Attributes

  *   `availableQuantity` (*type:* `integer()`, *default:* `nil`) - Optional. Quantity of the products in stock when a user event happens. Optional. If provided, this overrides the available quantity in Catalog for this event. and can only be set if `stock_status` is set to `IN_STOCK`. Note that if an item is out of stock, you must set the `stock_state` field to be `OUT_OF_STOCK`. Leaving this field unspecified / as zero is not sufficient to mark the item out of stock.
  *   `currencyCode` (*type:* `String.t`, *default:* `nil`) - Optional. Currency code for price/costs. Use three-character ISO-4217 code. Required only if originalPrice or displayPrice is set.
  *   `displayPrice` (*type:* `number()`, *default:* `nil`) - Optional. Display price of the product (e.g. discounted price). If provided, this will override the display price in Catalog for this product.
  *   `id` (*type:* `String.t`, *default:* `nil`) - Required. Catalog item ID. UTF-8 encoded string with a length limit of 128 characters.
  *   `itemAttributes` (*type:* `GoogleApi.RecommendationEngine.V1beta1.Model.GoogleCloudRecommendationengineV1beta1FeatureMap.t`, *default:* `nil`) - Optional. Extra features associated with a product in the user event.
  *   `originalPrice` (*type:* `number()`, *default:* `nil`) - Optional. Original price of the product. If provided, this will override the original price in Catalog for this product.
  *   `quantity` (*type:* `integer()`, *default:* `nil`) - Optional. Quantity of the product associated with the user event. For example, this field will be 2 if two products are added to the shopping cart for `add-to-cart` event. Required for `add-to-cart`, `add-to-list`, `remove-from-cart`, `checkout-start`, `purchase-complete`, `refund` event types.
  *   `stockState` (*type:* `String.t`, *default:* `nil`) - Optional. Item stock state. If provided, this overrides the stock state in Catalog for items in this event.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :availableQuantity => integer() | nil,
          :currencyCode => String.t() | nil,
          :displayPrice => number() | nil,
          :id => String.t() | nil,
          :itemAttributes =>
            GoogleApi.RecommendationEngine.V1beta1.Model.GoogleCloudRecommendationengineV1beta1FeatureMap.t()
            | nil,
          :originalPrice => number() | nil,
          :quantity => integer() | nil,
          :stockState => String.t() | nil
        }

  field(:availableQuantity)
  field(:currencyCode)
  field(:displayPrice)
  field(:id)

  field(:itemAttributes,
    as:
      GoogleApi.RecommendationEngine.V1beta1.Model.GoogleCloudRecommendationengineV1beta1FeatureMap
  )

  field(:originalPrice)
  field(:quantity)
  field(:stockState)
end

defimpl Poison.Decoder,
  for:
    GoogleApi.RecommendationEngine.V1beta1.Model.GoogleCloudRecommendationengineV1beta1ProductDetail do
  def decode(value, options) do
    GoogleApi.RecommendationEngine.V1beta1.Model.GoogleCloudRecommendationengineV1beta1ProductDetail.decode(
      value,
      options
    )
  end
end

defimpl Poison.Encoder,
  for:
    GoogleApi.RecommendationEngine.V1beta1.Model.GoogleCloudRecommendationengineV1beta1ProductDetail do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
